import instance from '@/utils/http'
/**
 * @description 获取订单详情
 */
export const getOrderDetail = () => instance.request({
  url: "/order/trade"
})

/**
 * @description 获取订单地址
 */
export const getOrderAddress = () => instance.request({
  url: "/userAddress/getOrderAddress"
})

/**
 * @description 立即购买
 * @param {String} goodsId string 商品的 ID
 * @param {String} blessing 祝福语
 */
export const orderBuy = ({
  goodsId,
  blessing
}) => instance.request({
  url: `/order/buy/${goodsId}`,
  data: {
    blessing
  }
})

/**
 * @description 提交订单
 * @param 
 */
export const submitOrder = (data) => {
  return instance.request({
    url: '/order/submitOrder',
    method: 'post',
    data
  })
}

/**
 * @description 微信预支付信息
 * @param {String} 订单ID
 */
export const getWebchatOrder = (orderNo) => instance.request({
  url: `/webChat/createJsapi/${orderNo}`
})

/**
 * @description 微信支付状态查询
 * @param {String} 订单ID
 */
export const getWebchatOrderStateSel = (orderNo) => instance.request({
  url: `/webChat/queryPayStatus/${orderNo}`
})

/**
 * @description 获取订单列表
 * @param {String} page 页码
 * @param {String} limit 每页请求条数
 */
export const getOrderList = ({
  page,
  limit
}) => instance.request({
  url: `/order/order/${page}/${limit}`
})